package com.example.demo.controller;

import com.example.demo.myInterface.TestInterface;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.cloud.context.config.annotation.RefreshScope;
import org.springframework.web.bind.annotation.CrossOrigin;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RestController;

import java.io.UnsupportedEncodingException;

@RefreshScope
@RestController
public class TestController {

    @Autowired
    private TestInterface testInterface;

    @Value("${remoteGitConsumerOne}")
    private String remoteGitConsumerOne;

    @CrossOrigin
    @RequestMapping(value = "/api/test",method = RequestMethod.GET, produces = "application/json; charset=UTF-8")
    public String test(){
        try {
            System.out.println(new String(remoteGitConsumerOne.getBytes("iso-8859-1"),"UTF-8"));
        } catch (UnsupportedEncodingException e) {
            e.printStackTrace();
        }
        return testInterface.test();
    }
}
